<?xml version="1.0" encoding="utf-8" ?>
<taskrunner name="check.local.db" version="1.0" date="2008-10-30" maxthreads="5">

  <!-- checks installed version. -->

  <includes>
    <file name="vida.install.settings.xml" />
  </includes>

  

  <tasks>

    <task name="get.installed.version" typename="@SqlServer.ExecuteScalar">
      <dependencies list="accessserver.is.attached,start.sqlexpress.service"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="database" value="${db.accessserver.name}"/>
        <parameter name="sql" value="select ip.PublicationTitle from serverconsistency sc, installedpublication ip"/>
        <parameter name="throwException" value="false"/>

        <!-- out parameters -->
        <parameter name="output.value" value="installed.version"/>

      </parameters>
    </task>

    <task name="installed.version" typename="@WriteInformation">
      <dependencies list="get.installed.version"/>
      <parameters>
        <parameter name="message" value="Installed version: ¤{installed.version}"/>
      </parameters>
    </task>

    <task name="get.installed.update" typename="@SqlServer.ExecuteScalar">
      <dependencies list="start.sqlexpress.service"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="database" value="${db.accessserver.name}"/>
        <parameter name="sql" value="select ISNULL(iu.UpdateTitle,' ') AS UpdateTitle from serverconsistency sc, installedpublication ip LEFT OUTER JOIN InstalledUpdate iu ON sc.fkInstalledUpdate = iu.Id"/>
        <parameter name="throwException" value="false"/>

        <!-- out parameters -->
        <parameter name="output.value" value="update.title"/>

      </parameters>
    </task>

    <task name="SetKeepLocalDb" condition="¤{installed.version}=${previous.release} OR ¤{installed.version}=${release}" typename="@SetGlobalProperty">
      <description>
        Sets the global property KeepLocalDb to true if the above condition evaluates to true.
      </description>
      <dependencies list="get.installed.version"/>
      <parameters>
        <parameter name="property.name" value="KeepLocalDb"/>
        <parameter name="property.value" value="true"/>
      </parameters>
    </task>

  </tasks>
  
</taskrunner>